package demo.binarytree;

/**
 * 二叉树测试
 */
public class BinaryTreeDemo {
    public static void main(String[] args) {
        //先需要创建一颗二叉树
        BinaryTree binaryTree = new BinaryTree();
        //创建需要的结点
        HeroNode root = new HeroNode(1, "宋江");
        HeroNode node2 = new HeroNode(2, "吴用");
        HeroNode node3 = new HeroNode(3, "卢俊义");
        HeroNode node4 = new HeroNode(4, "林冲");
        HeroNode node5 = new HeroNode(5, "武松");
        HeroNode node6 = new HeroNode(6, "鲁智深");
        HeroNode node7 = new HeroNode(7, "杨志");
        //说明，我们先手动创建该二叉树，后面我们学习递归的方式创建而常数
        root.setLeft(node2);
        root.setRight(node3);
        node2.setLeft(node4);
        node2.setRight(node5);
        node3.setLeft(node6);
        node3.setRight(node7);

        binaryTree.setRoot(root);

        //测试：
        System.out.println("前序遍历");//1,2,4,5,3,6,7
        binaryTree.preOrder();
        System.out.println("中序遍历");//4,2,5,1,6,3,7
        binaryTree.infixOrder();
        System.out.println("后序遍历");//4,5,2,6,7,3,1
        binaryTree.postOrder();
    }
}

